package eredis

import (
	"github.com/garyburd/redigo/redis"
	"ego/utils"
	//"fmt"
)

//封装redigo 有bug

var Client redis.Conn

func init() {
	c,err:= redis.Dial("tcp",utils.RedisPort)
	utils.CheckError(err)
	Client = c
	//value,err:=redis.String(Client.Do("get","go"))
	//if err !=nil{
	//	fmt.Println("没有该数据")
	//}else {
	//	fmt.Println(value)
	//}

	//value,err:=Client.Do("set","gogo","gogogo")

	//value,err := GetString("lin")
	//if err !=nil{
	//	fmt.Println(err)
	//} else {
	//	fmt.Println(value)
	//}

	//value,err:=redis.String(Get("go"))
	//if err !=nil{
	//	fmt.Println(err)
	//} else {
	//	fmt.Println(value)
	//}

	//value,err:=Set("lin","lxy")
	//if err !=nil{
	//	fmt.Println(err)
	//}else {
	//	fmt.Println(value)
	//}
}

func RedigoConn()redis.Conn  {
	return Client
}

func Get(args ...interface{})(reply interface{}, err error)  {
	return Client.Do("get",args)
}

func GetString(args ...interface{})(reply string, err error)  {
	return redis.String(Get(args))
}

func Set(key string,args ...interface{})(reply interface{}, err error)  {
	return Client.Do("set",key,args)
}

func Close()  {
	Client.Close()
}